package com.comprehensive.personalnotes.controller;

import com.comprehensive.common.dto.FolderFlieInfo;
import com.comprehensive.personalnotes.service.NotesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/notes")
public class NotesController {
    private final NotesService notesService;
    @Autowired
    public NotesController(NotesService notesService) {
        this.notesService = notesService;
    }
    @GetMapping("/listFiles")
    ResponseEntity<List<FolderFlieInfo>> listFiles(@RequestParam("directoryPath") String directoryPath){
        return notesService.listFiles(directoryPath);
    }
    @GetMapping("/getMarkdownContent")
    ResponseEntity<String> getMarkdownContent(@RequestParam String filePath){
        return notesService.getMarkdownContent(filePath);
    }
    @PostMapping("/saveMarkdownContent")
    ResponseEntity<Void> saveMarkdownContent(@RequestParam String filePath,@RequestParam String content) {
        return notesService.saveMarkdownContent(filePath, content);
    }

}
